package com.acmedcare.framework.plugin.sample.data;

import com.acmedcare.framework.exchange.center.core.metadata.AdapterMapping;
import com.acmedcare.framework.exchange.center.core.metadata.IDataAdapter;
import com.acmedcare.framework.exchange.center.core.metadata.Response;
import com.acmedcare.framework.plugin.sample.Application;
import com.acmedcare.framework.plugin.sample.dto.TaskRunner;
import com.acmedcare.framework.plugin.sample.repository.TaskRunnerMapper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@AdapterMapping("DemoAdapter")
@SuppressWarnings("unused")
public class DemoAdapter implements IDataAdapter {

  @Override
  public Response get(HashMap<String, String> args) {

    try {

      TaskRunnerMapper mapper = (TaskRunnerMapper) Application.configurableApplicationContext
          .getBean("taskRunnerMapper");
      List<TaskRunner> taskRunners = mapper.getRunners();

      return new Response(200, taskRunners);
    } catch (Exception e) {

      return new Response(500, e.getMessage());
    } finally {

    }
  }

  public Response post(DemoDto body) {

    return new Response(200, body);
  }

  public Response put(DemoDto body) {
    return new Response(200, new ArrayList());
  }

  public Response delete(DemoDto body) {
    return new Response(200, body);
  }
}
